<template>
  <div class="articleCard" @click.stop="toDetails(attrs)">
    <img :src="attrs.pImg" alt="" class="articleCard_img" />
    <div class="articleCard_right">
      <div class="articleCard_first">
        <span class="articleCard_first_tag">{{ attrs.tName }}</span>
        <h3>{{ attrs.titleName }}</h3>
      </div>
      <div>
        <span class="articleCard_first_time">{{attrs.pTime}}</span>
        <!-- <span class="articleCard_first_time">{{
          common.changeTimeFormat(attrs.pTime)
        }}</span> -->
        <span class="articleCard_first_status" @click.stop="toRevise(attrs)">修改</span>
      </div>
      <div class="articleCard_bottom">
        <div>
          <i class="iconfont icon-chakan"></i>
          <span>阅读量{{ attrs.viewNums }}</span>
        </div>
        <div>
          <i class="iconfont icon-xinxi"></i>
          <span>评论{{ attrs.replyNums }}</span>
        </div>
        <div>
          <i class="iconfont icon-icon becomeHand"></i>
          <span>点赞{{ 0 }}</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    attrs: {
      type: Object,
      default () {
        return {
          status:[
            {
              id:1,
              name:"进行中"
            },
            {
              id:2,
              name:"已通过"
            },
            {
              id:3,
              name:"未通过"
            }
          ],
        }
      }
    }
  },
  data () {
    return {}
  },
  methods: {
    sendPost(item){
      this.$bus.$emit("postMes",item)
    },
    toRevise(item) {
      this.sendPost(item)
      this.$router.push("/submit/article")
    },
    toDetails (item) {
      console.log(item)
      let params = item
      console.log(params)
        this.$axios.updatePostView(params).then(res => {
          console.log(res)
          let detail = JSON.stringify(res.data)
          this.$router.push({
            path: '/details',
            query: {
              detail
            } // 要传递的参数
          })
        })

    },
  },
  beforeDestroy(){
    this.sendPost()
  }
}
</script>
<style scoped>
.articleCard {
  margin: 20px 0;
  padding: 15px;
  border: 1px solid rgb(241, 241, 241);
  border-radius: 5px;
  display: flex;
}
.articleCard_img {
  width: 200px;
  border-radius: 5px;
  margin-right: 15px;
}
.articleCard_right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 14px;
}
.articleCard_first {
  display: flex;
}
.articleCard_first_tag {
  padding: 2px 5px;
  border: 1px solid rgb(218, 217, 217);
  border-radius: 15px;
  margin-right: 10px;
  font-size: 12px;
}
.articleCard_first_time {
  color: rgb(218, 217, 217);
  margin-right: 50px;
}
.articleCard_first_status {
  color: rgb(112 197 245);
}
.articleCard_bottom {
  display: flex;
}
.articleCard_bottom > div {
  margin-right: 20px;
}
</style>
